package com.jd.gitdemo0702.bean;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

/**
 * @Author LQWQK
 * @Description 通用的返回结果类
 * @Date 2025-07-02 17:52:19
 * @Version 1.0
 */
@Data
@ToString
@AllArgsConstructor
@NoArgsConstructor
public class R<T> {
    private String code;
    private String msg;
    private T data;

    public static <T> R<T> success(String code, String msg) {
        return error(code, msg);
    }
    public static <T> R<T> success(String code, String msg, T data) {
        R<T> r = new R<>();
        r.setCode(code);
        r.setMsg(msg);
        r.setData(data);
        return r;
    }

    public static <T> R<T> error(String code, String msg) {
        R<T> r = new R<>();
        r.setCode(code);
        r.setMsg(msg);
        return r;
    }
    public static <T> R<T> error(String code, String msg, T data) {
        R<T> r = new R<>();
        r.setCode(code);
        r.setMsg(msg);
        r.setData(data);
        return r;
    }
}
